home *** CD-ROM | disk | FTP | other *** search
/ Cracking 2 / Cracking II..iso / Texty / crackme / Level1.txt < prev    next >
Encoding:
Text File  |  1998-05-11  |  5.2 KB  |  105 lines

  1. [ Cracking Level-1  Step-by-Step Introduction ]
  2. ===============================================
  3.  
  4. This is level-1, the most basic registration routine designed to help
  5. beginners to get started.  It is in a way to get to know Softice.
  6. You will almost never find such simple registration routine in any real
  7. world sharewares.  But it is good to have an easy start!
  8. No username is require in this routine.  You just need the correct
  9. registration key.  Very simple!
  10.  
  11. Make sure you have Softice loaded before Windows.  You don't need
  12. the Softice Symbol loader, just as long as Softice is loaded then
  13. it is fine.  Then load up the "CrackMe" program, and type in any fake
  14. registration key you want.
  15.  
  16. Now, what you will need to do first is to set a break point.
  17. Go into Softice by pressing [Ctrl]-D.  In Softice command window, 
  18. type in: bpx GetDlgItemTextA
  19. GetDlgItemTextA is used by CrackMe to obtain the registration key
  20. entered by the user.  When you hit the button "Validate Registration Key".
  21. You will noticed that Softice should take over the Window.  That is
  22. because once you hit the button, CrackMe calls the GetDlgItemTextA
  23. API function in order to obtain the registration key entered by the user.
  24. And at this moment, Softice will break into the program.  Then everything
  25. that Windows is doing will all be stopped.
  26.  
  27. You should now be inside of the GetDlgItemTextA function, which it
  28. belongs to USER32.DLL.  So leave the function by pressing [F12]; you
  29. don't need to know the details of what the function does. Just know
  30. that it retrieves a text string and saves it to some memory location.
  31. After pressing [F12] only once, you should be in MFC42.DLL.  You also
  32. don't need to know what it is doing here, just leave it by pressing
  33. [F12] again.  Now, you'll be back into the CrackMe program's code as
  34. indicated by the text between the code and command window in Softice.
  35.  
  36. You will see several important things here, and you should see
  37. assembly codes that are similar to what you see here...
  38. The line you'll be at after the leaving the break point is ":004019DD"
  39. That's after calling the GetDlgItemTextA function
  40. (the code before was obtained from W32Dasm, which is very similar to
  41. what you should see under Softice. I've also added a few comments.)
  42. ---------------------------------------------------------------------
  43. :004019D8 E801120000      Call 00402BDE  ; MFC42.GetDlgItemTextA
  44. :004019DD 8D542410        lea edx, dword ptr [esp+10]
  45. :004019E1 8D44242C        lea eax, dword ptr [esp+2C]
  46. :004019E5 52              push edx ; -> push secret key string onto stack
  47. :004019E6 50              push eax ; -> push entered password onto stack
  48.  
  49.                           ; compare the two strings on the stack
  50. :004019E7 FF1508404000    Call dword ptr [00404008]  ; KERNEL32.lstrcmpA
  51. :004019ED 85C0            test eax, eax  ; if 2 strings equal, then eax = 0
  52. :004019EF 755A            jne 00401A4B   ; jump/quit/error if eax is not 0
  53. :004019F1 6870434000      push 00404370
  54. :004019F6 8D4C2410        lea ecx, dword ptr [esp+10]
  55. ----------------------------------------------------------------------
  56. To see that GetDlgItemText really did retrieved the string you've
  57. entered for the registration key. Do the following...
  58.  
  59. If you are not currently at line :004019E5, then hit [F10] until
  60. you get there.  [F10] means step over each instruction. Then type in 
  61. "d eax" in the the command window. (That says display the memory
  62. contents pointed to by the EAX register). Now in the data window, 
  63. you should see the text string in which you've entered.
  64.  
  65. If you scroll the data window up a little, or type in "d edx" you should
  66. see some weird string sitting in the memory.  And the string should read 
  67. something like "qJT62aWfviq0P57JGs2FelQkX", humm... suspicious???
  68.  
  69. What's more weird is that the address of the two strings are being
  70. passed onto the "lstrcmpA" function at address :004018E2
  71.   push edx ; - points to an unkown misterious string
  72.   push eax ; - points to user's registration code
  73.   call [KERNEL32!lstrcmp] ; - calls the string compare function
  74. (lstrcmpA is a Kernel function that compares two strings)
  75.  
  76. Obviously, it is comparing the two strings.  And you know that
  77. the return value is in the EAX register.  So the next line that
  78. says "test eax, eax" should be testing something is that returned
  79. from the "lstrcmpA" function called previously!
  80.  
  81. Now, you're almost done with cracking this registration routine.
  82. There are different ways in which you would choose to do at this point.
  83. You can continue tracing the program and see what happens.  If you 
  84. continue the trace the execution, you'll soon end up with the
  85. MessageBox that tells you that you've entered an invalid code.
  86. Or you can leave Softice right away, return to Windows, then enter 
  87. the weird string as the key, and see what happens.
  88. (you might want to disable the break point first)
  89.  
  90.  
  91. Here is the actual C++ source code
  92. ----------------------------------
  93.  
  94. void CCrackMeDlg::Validate()
  95. {
  96.   char key[30] = "\0";
  97.   char teststr[] = "qJT62aWfviq0P57JGs2FelQkX";
  98.  
  99.   GetDlgItemText(IDC_KEY, key, 30); // get the key entered
  100.   if (lstrcmp(key, teststr) == 0)  // compare the 2 keys
  101.     // give message for correct key
  102.   else
  103.     // give message for WRONG correct key
  104. }
  105.